#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class Solution {
public:
    int minArray(vector<int>& numbers) {
        //二分法
        int l = 0, r = numbers.size()-1;
        int mid = l + (r-l) / 2;//中间值
        while(l<r){
            if(numbers[mid]<numbers[r]){
                //则舍弃右半边
                r = mid;
            }
            else if(numbers[mid]>numbers[r]){
                //如果比右侧还大，说明答案在mid~r中间
                //则舍弃左半边
                l = mid+1;
            }else r--;
            
            mid = l + (r-l) / 2;
        }
        return numbers[mid];
    }
};
int main(){
    vector<int> nums = {3,4,5,1,2};
    cout<<Solution().minArray(nums)<<endl;
    return 0;
}